package snake.demo.obj;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import snake.demo.common.GameWin;

import java.awt.*;

/**
 * @author A
 * @version 1.0
 * @description: 游戏obj
 * @date 2022/10/21 17:32
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class GameObj {

    //图片
    Image img;

    //坐标
    int x;
    int y;

    //宽高
    int width=30;
    int height=30;

    //窗口类的引用
    GameWin frame;

    public GameObj(Image img, int x, int y, GameWin frame) {
        this.img=img;
        this.x=x;
        this.y=y;
        this.frame=frame;
    }

    /**
     * @description: 绘制自身
     * @author: chensiwei
     * @date: 2022/10/24 10:52
     * @param: [g]
     * @return: void
     **/
    public void paintSelf(Graphics g){
        //
        g.drawImage(img, x, y, null);
    }

}
